package com.yhl.springtest.proxy_dynamic;


import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author: yanghl
 * @description: TODO
 * @date: 2023/8/15 17:03
 */
public class StudentInvocationHandler<T> implements InvocationHandler {
    T target;
    public StudentInvocationHandler(T target){
        this.target = target;
    }

    /**
     * o: 代表动态代理对象
     * method: 代表正在执行的方法
     * objects: 代表调用目标方法时传入的实参
    */
    @Override
    public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
        System.out.println("代理执行" + method.getName() + "方法");
        Object result = method.invoke(target, objects);
        return result;
    }
}

